package info.techgeek.labs.java5Features.thread.arv;

/*
import info.techgeek.dis.dao.ICMDBAccessDAO;
import info.techgeek.dis.helper.JiraEventListenerProperties;
import info.techgeek.dis.view.JiraFieldsBean;

import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.exception.CreateException;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.IssueFactory;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItemImpl;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.project.Project;

/**
 * CRQToTaskThreadPoolReader Execute when thread pool execute from listner
 * 
 * @author techgeek
 * 
 */
/*
public class CRQToTaskThreadPoolReader implements Runnable {
	private static final Logger LOG = Logger
			.getLogger(CRQToTaskThreadPoolReader.class);

	JiraFieldsBean jiraFieldsBean;

	public JiraFieldsBean getJiraFieldsBean() {
		return jiraFieldsBean;
	}

	public void setJiraFieldsBean(JiraFieldsBean jiraFieldsBean) {
		this.jiraFieldsBean = jiraFieldsBean;
	}

	/**
	 * Issue is created using API when CRQTOTask listner fires.
	 */
/*
	public void run() {

		LOG.warn("******************************************************");
		LOG.warn("*  CRQToTaskThreadPoolReaderStarted********************");
		LOG.warn("*******************************************************");
		ComponentManager componentManager = ComponentManager.getInstance();
		JiraEventListenerProperties resourceBundle = new JiraEventListenerProperties();
		resourceBundle.readPropertyFile();
		CustomFieldManager fieldManager = ComponentManager.getInstance()
				.getCustomFieldManager();
		Project project = componentManager.getProjectManager()
				.getProjectObjByKey(jiraFieldsBean.getComponent());
		// IssueObject is Created
		IssueFactory issueFactory = componentManager.getIssueFactory();
		MutableIssue issueObject = issueFactory.getIssue();
		issueObject.setProject(project.getGenericValue());
		issueObject.setSummary(jiraFieldsBean.getSummary());
		issueObject.setIssueTypeId("3");
		issueObject.setPriorityId(jiraFieldsBean.getPriority());
		issueObject.setReporter(jiraFieldsBean.getRemoteUser());
		issueObject.setAssignee(project.getLead());
		CustomField customField = fieldManager
				.getCustomFieldObject(resourceBundle.scadenzaDate);
		issueObject.setCustomFieldValue(customField, jiraFieldsBean
				.getScadenza());
		LOG.warn(" CRQToTaskThreadPoolReaderStarted Scadenza......"
				+ jiraFieldsBean.getScadenza());
		
		CustomField customFieldInizio = fieldManager
		.getCustomFieldObject(resourceBundle.inizio);
		issueObject.setCustomFieldValue(customFieldInizio, jiraFieldsBean
				.getInizio());
		LOG.warn(" CRQToTaskThreadPoolReaderStarted Inizio is......"
				+ jiraFieldsBean.getInizio());
		
		IssueManager issueManager = ComponentManager.getInstance()
				.getIssueManager();
		try {

			CustomField nomeProgetto = fieldManager
					.getCustomFieldObject(resourceBundle.progettoAttivitaId);
			issueObject.setCustomFieldValue(nomeProgetto, jiraFieldsBean
					.getActivitiyId());
			LOG.warn(" CRQToTaskThreadPoolReaderStarted Activity Id......"
					+ jiraFieldsBean.getActivitiyId());

			CustomField crqField = fieldManager
					.getCustomFieldObject(resourceBundle.crqSummary);
			issueObject.setCustomFieldValue(crqField, jiraFieldsBean
					.getCrqIssueKey());
			LOG.warn(" CRQToTaskThreadPoolReaderStarted CrqIssueKey......"
					+ jiraFieldsBean.getCrqIssueKey());
			// Issue Created
			issueManager.createIssue(jiraFieldsBean.getRemoteUser(),
					issueObject);
			LOG
					.warn(" CRQToTaskThreadPoolReaderStarted Task Issue Created ......"
							+ issueObject.getKey());
			// After Created Issue Custom Fields Values Are Updated.
			IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
			CustomField taskAmbient = fieldManager
					.getCustomFieldObject(resourceBundle.jrambiente);
			FieldLayoutItemImpl fieldLayoutItem2 = new FieldLayoutItemImpl(
					taskAmbient, "", false, false);
			taskAmbient.updateValue(fieldLayoutItem2, issueObject,
					new ModifiedValue(issueObject
							.getCustomFieldValue(taskAmbient), jiraFieldsBean
							.getAmbiente()), changeHolder);
			LOG.warn("Ambiente Updated");

			CustomField classificatione = fieldManager
					.getCustomFieldObject(resourceBundle.classificazioneId);
			FieldLayoutItemImpl fieldLayoutItem = new FieldLayoutItemImpl(
					classificatione, "", false, false);
			classificatione.updateValue(fieldLayoutItem, issueObject,
					new ModifiedValue(issueObject
							.getCustomFieldValue(classificatione),
							jiraFieldsBean.getClassificazioneImpatto()),
					changeHolder);
			LOG.warn("Classificzione updated");

			CustomField customFieldScadenza = fieldManager
					.getCustomFieldObjectByName(resourceBundle.scadenzaFieldName);
			LOG.warn("Scadenza Field Name::::" + customFieldScadenza);
			LOG.warn("Scadenza Value Is::::" + jiraFieldsBean.getScadenza());
			FieldLayoutItemImpl fieldLayoutItemScadenza = new FieldLayoutItemImpl(
					customFieldScadenza, "", false, false);
			customFieldScadenza.updateValue(fieldLayoutItemScadenza,
					issueObject, new ModifiedValue(issueObject
							.getCustomFieldValue(customFieldScadenza),
							jiraFieldsBean.getScadenza()), changeHolder);
			LOG.warn("Scadenza updated");

			CustomField customFieldDescription = fieldManager
					.getCustomFieldObjectByName(resourceBundle.description);
			LOG.warn("Description Field Name::::" + customFieldDescription);
			LOG.warn("Description Value Is::::"
					+ jiraFieldsBean.getDescription());
			FieldLayoutItemImpl fieldLayoutItemDescription = new FieldLayoutItemImpl(
					customFieldDescription, "", false, false);
			customFieldDescription.updateValue(fieldLayoutItemDescription,
					issueObject, new ModifiedValue(issueObject
							.getCustomFieldValue(customFieldDescription),
							jiraFieldsBean.getDescription()), changeHolder);
			LOG.warn("Description updated");

			// Setting Project ID To retrieve Application Id From DB
			LOG.warn("Project Id is " + project.getId());
			jiraFieldsBean.setProjectId(project.getId());
			ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
					new String[] { "JMSReceiver.Spring.cfg.xml" });
			ICMDBAccessDAO icmdbAccessDAO = (ICMDBAccessDAO) appContext
					.getBean("CMDBAccessDAO");
			icmdbAccessDAO.selectApplicazioneForTask(jiraFieldsBean);

			CustomField customFieldTaskApplicatione = fieldManager
					.getCustomFieldObject(resourceBundle.applicationServizo);
			FieldLayoutItemImpl fieldLayoutItemApplicatione = new FieldLayoutItemImpl(
					customFieldTaskApplicatione, "", false, false);
			customFieldTaskApplicatione.updateValue(
					fieldLayoutItemApplicatione, issueObject,
					new ModifiedValue(issueObject
							.getCustomFieldValue(customFieldTaskApplicatione),
							jiraFieldsBean.getApplicationId()), changeHolder);
			LOG.warn("Applicazione updated");

		} catch (CreateException e) {

			LOG.warn("CreateException" + e);

		}
	}

}
*/
